var app = getApp();
const api = require('../../utils/api.js');
import validate from '../../utils/WxValidate.js'

Page({
  /**
   * 页面的初始数据
   */
  data: {
    userId : 0,
    patnerList: [],
    relactions: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.data.userId = wx.getStorageSync('userId')
    wx.showToast({
      title: '正在加载',
      icon: 'loading',
      duration: 10000,
    });

    const userId = this.data.userId
    api.getAllPartner({
      query: {
        userId
      },
      success: (res) => {
        console.log(res)
        let patnerList = JSON.parse(res.data).data;
        console.log(patnerList)
        this.setData({
          patnerList: patnerList,
          loading: false,
        });
        wx.hideToast();
      },
    });
  },

  addPartner: function(e) {
    wx.navigateTo({
      url: '../add-partner/index',
    });
  },

  screen: function (e) {
    var params = e.detail.value;
    // params.type = wxb.that.data.index;

    var index = wxb.that.data.index;
    var chufa = params.chufa;
    var mudidi = params.mudidi;
    var tujing = params.tujing;
    var begin = wxb.that.data.begin;
    var time = wxb.that.data.time;
    var num = wxb.that.data.nIndex;

    wx.reLaunch({
      url: '/pages/index/index?type=' + index + '&chufa=' + chufa + '&mudidi=' + mudidi + '&tujing=' + tujing + '&begin=' + begin + '&time=' + time + '&num=' + num,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
})